#define  _CRT_SECURE_NO_WARNINGS
#include"list.h"
using namespace std;

namespace my_list
{
	void test_list1()
	{
		list<int> lt1;
		lt1.push_back(1);
		lt1.push_back(2);
		lt1.push_back(3);
		lt1.push_back(4);
		list<int>::iterator it = lt1.begin();
		while (it != lt1.end())
		{
			*it += 10;
			cout << *it << " ";
			++it;
		}
		cout << endl;

		lt1.push_back(1);
		lt1.push_back(2);
		lt1.push_front(3);
		lt1.push_front(4);
		for (auto& e : lt1)
		{
			cout << e << " ";
		}
		cout << endl;

		lt1.pop_back();
		lt1.pop_front();
		for (auto& e : lt1)
		{
			cout << e << " ";
		}
		cout << endl;
		cout << lt1.size() << endl;
	}

	void test_list2()
	{
		list<int> lt1;
		lt1.push_back(1);
		lt1.push_back(2);
		lt1.push_front(3);
		lt1.push_front(4);
		for (auto& e : lt1)
		{
			cout << e << " ";
		}
		cout << endl;

		list<int> lt2(lt1);
		for (auto& e : lt1)
		{
			cout << e << " ";
		}
		cout << endl;

		list<int> lt3;
		lt3 = lt1;
		for (auto& e : lt1)
		{
			cout << e << " ";
		}
	}

	struct AA
	{
		int _a1;
		int _a2;

		AA(int a1 = 1, int a2 = 1)
			:_a1(a1)
			, _a2(a2)
		{}
	};

	void test_list3()
	{
		list<int> lt1 = { 1,2,3,4 };
		for (auto& e : lt1)
		{
			cout << e << " ";
		}
		cout << endl;

		list<AA> lt2 = { {1,1},{2,2},{3,3},{4,4} };
		list<AA>::iterator it = lt2.begin();
		while (it != lt2.end())
		{
			//cout << (*it)._a1 << ":" << (*it)._a2 << endl;
			//cout << it->->_a1 << ":" << it->->_a2 << endl;
			cout << it->_a1 << ":" << it->_a2 << endl;
			++it;
		}

		list<AA>::iterator lit = lt2.begin();
		while (lit != lt2.end())
		{
			cout << lit.operator->()->_a1 << ":" << lit.operator->()->_a2 << endl;
			++lit;
		}
	}
}

int main()
{
	my_list::test_list3();
	return 0;
}